<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .red {
            color: red
        }
    </style>
    <script src="../../jquery.min.js"></script>
</head>

<body>
    <div>
        <p>这是一个p标签</p>
    </div>
    <div>
        <p>这是一个p标签</p>
    </div>
</body>
<script>
    $(function() {
        $("p").on("click", function() {
            $(this).toggleClass('red')
        })
    })
</script>

</html>